#!/bin/sh

# Copyright © 2009, 2010, 2011 Jakub Wilk
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.

if ! command -v "$1" >/dev/null
then
  printf 'Usage: %s xgettext [xgettext-option]...\n' "$0" >&2
  exit 1
fi
options=$(cat <<EOF
--c++ \
--keyword=_ --keyword=N_
--flag=_:1:pass-c-format
--flag=N_:1:pass-c-format
--flag=string_format:1:c-format
EOF
)

grep -E '^#( |$)' "$0" | sed -e 's/2009/2007, 2008, &/'
"$@" $options -o - \
| sed \
  -e '/^# SOME DESCRIPTIVE TITLE/,/^#.*YEAR[.]$/ d' \
  -e '/^msgstr ""$/,/^$/ s/CHARSET/UTF-8/'
